home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 7
/
FM Towns Free Software Collection 7.iso
/
t_os
/
gpen32k
/
source.exe
/
LIB
/
OSRC
/
MENU.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-09
|
4KB
|
222 lines
/*
Towns Menu-Bar ver. 0.001
Copyright(C) 1993 Okome
*/
#include <string.h>
#include <EGB.H>
#include <MOS.H>
#include <sidework.h>
#include <normlib.h>
#include <okome.h>
extern char work[];
extern char *MEN_title[];
extern int MEN_kazu[];
static int mex[16], mel[16], ebf;
int MEN_si=0, MEN_ss;
static int ml( int i )
{
int k, l=0;
for (k=0; k<=i; k++)
l+=MEN_kazu[k];
return (l);
}
static int ubs( int i, int m )
{
static int j=-1, n=0;
int k, l;
if (j != i)
{
if (j >= 0)
{
ubox2( mex[j], 0, mex[j+1]-1, 19, 15, 8 );
OKM_gth(mex[j],20,mex[j]+mel[j],23+MEN_kazu[j+1]*16,0);
}
j = i;
n = 0;
if (i >= 0)
{
ubox2( mex[i], 0, mex[i+1]-1, 19, 1+(i==0)*7, 1+(i==0)*7 );
OKM_gth(mex[j],20,mex[j]+mel[j],23+MEN_kazu[j+1]*16,1);
boxbf( mex[i], 20, mex[i]+mel[i]-2, 21+MEN_kazu[i+1]*16, 8, 15 );
boxb( mex[i], 20, mex[i]+mel[i]-1, 22+MEN_kazu[i+1]*16, 8 );
boxb( mex[i], 20, mex[i]+mel[i], 23+MEN_kazu[i+1]*16, 8 );
l = ml(i);
for (k=0; k<MEN_kazu[i+1]; k++)
{
font12( mex[i]+8, 34+k*16, MEN_title[l+k], 8 );
}
}
}
if ( i>=0 )
{
if ( m!=n )
{
EGB_writeMode( work, 4 );
if (n>0)
{
boxf( mex[i]+1, n*16+5, mex[i]+mel[i]-3, n*16+20, 7 );
}
if (m>0)
{
boxf( mex[i]+1, m*16+5, mex[i]+mel[i]-3, m*16+20, 7 );
}
EGB_writeMode( work, 0 );
n = m;
}
if (m > 0)
{
if (i==0 && MEN_si<m && MEN_si+MEN_ss-1>m)
{
sdk_chain(m-MEN_si);
return (8000+m-MEN_si);
} else {
return (i*100+m);
}
}
}
return (0);
}
static int menx(int mx)
{
int i = 1;
while ( mex[i] <= mx )
i++;
return (i-1);
}
static int mebox( int mb, int k )
{
int i = 0, j, mx, my, l;
l = k*23;
while (mb != 0)
{
MOS_rdpos( &mb, &mx, &my );
j=i;
i = ( mx >= 610-l && mx <=629-l && my < 20 ) ? 1 : 0 ;
if (j!=i)
{
MOS_disp( 0 );
ubox2( 610-l, 0, 629-l, 19, 15-i*7, 8 );
MOS_disp( 1 );
}
}
MOS_disp( 0 );
ubox2( 610-l, 0, 629-l, 19, 15, 8 );
MOS_disp( 1 );
return (i);
}
int MEN_menu( int mb, int mx, int my )
{
int p, i, r = 0, j = -1, z = 1, mb2;
p = EGB_getWritePage( 0, 0 );
EGB_writePage( work, 0 );
if ( mb && mex[MEN_kazu[0]] > mx && my < 20 )
{
while ( z != 0 )
{
mb2 = mb;
MOS_rdpos( &mb, &mx, &my );
if ( mex[MEN_kazu[0]] > mx && my < 20 )
{
if ( mb )
{
i = menx(mx);
if ( j!=i || r )
{
MOS_disp( 0 );
r = ubs( i, 0 );
MOS_disp( 1 );
j = i;
}
z = 2;
} else {
z = 1;
}
}
if ( mex[j] <= mx && mex[j]+mel[j] >= mx &&
20 < my && my < 21 + MEN_kazu[j+1] * 16 )
{
if (mb!=0)
{ /* SUB menuの処理 */
i = (my - 21) / 16;
MOS_disp( 0 );
r = ubs( j, i+1 );
MOS_disp( 1 );
z = 3;
} else {
if ( z==3 && mb2 )
{
z = 0;
}
if ( z==2 )
{
z = 1;
}
}
} else {
if ( z==3 && mb)
{
MOS_disp( 0 );
r = ubs(j, 0);
MOS_disp( 1 );
z = 4;
}
if ( (mex[MEN_kazu[0]] > mx && my < 20)==0 )
{
if (((z==1) && mb) || ((z==2 || z==4) && mb==0))
{
z = 0;
}
}
}
}
MOS_disp( 0 );
ubs( -1, 0 );
MOS_disp( 1 );
do {
MOS_rdpos( &mb, &mx, &my );
} while( mb != 0 );
} else {
if ( mx >= 633-23*ebf && mx <= 629 && my < 20 && (629-mx) % 23 < 20)
{ /* ENDボタン */
i = (629-mx) / 23;
if (mebox( mb, i ))
r = 9999 - i;
}
}
EGB_writePage( work, p );
return (r);
}
void MEN_set( int b )
{
int i, j=0, k, l;
boxbf( 0, 0, 639, 19, 0, 7 );
ebf = b;
for (i = 0; i < MEN_kazu[0]; i++)
{
j += strlen(MEN_title[i])*6+34;
mex[i+1] = j;
boxf( mex[i], 0, j-1, 19, 1+(i==0)*7 );
ubox2( mex[i], 0, j-1, 19, 15, 8 );
font12( mex[i]+13, 16, MEN_title[i], 15 );
l = ml(i);
for (k=0; k<MEN_kazu[i+1]; k++)
{
if ( strlen(MEN_title[l+k])*6+16 > mel[i] )
mel[i] = strlen(MEN_title[l+k])*6+18;
}
}
for (i = 0; i < b; i++)
{
boxf( 610-i*23, 0, 629-i*23, 19, 8 );
ubox2( 610-i*23, 0, 629-i*23, 19, 15, 8 );
}
}